/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package user_gui;

import java.util.Arrays;
import java.util.Map;
import javax.swing.AbstractListModel;

/**
 *
 * @author Jônatas
 */
public class MapBasedListModel extends AbstractListModel {

    private Map<String, ? extends Object> myMap;

    public MapBasedListModel(Map<String, ? extends Object> myMap) {
        this.myMap = myMap;
    }

    public int getSize() {
        return myMap.size();
    }

    public Object getElementAt(int index) {

        String[] elementos = new String[myMap.size()];

        int i = 0;

        for (String elem : myMap.keySet()) {
            elementos[i++] = elem;
        }

        Arrays.sort(elementos);

        return elementos[index];
    }
}
